package com.econ.powercloud.ems.service.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.econ.powercloud.ems.dal.entity.EmsExportDataRecord;
import com.econ.powercloud.ems.dal.mapper.EmsExportDataRecordMapper;
import org.springframework.stereotype.Repository;

/**
 * @Author : zjf
 * @Description :
 * @Date : 2023/6/1 18:48
 * @Modified by : zjf
 */
@Repository
public class EmsExportDataRecordDAO extends ServiceImpl<EmsExportDataRecordMapper,EmsExportDataRecord> {

    public Page<EmsExportDataRecord> selectListByCondition(Integer type,Long startTime,Long endTime,String fileName,Integer status,
                                                           Integer pageNo,Integer pageSize){
        LambdaQueryWrapper<EmsExportDataRecord> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(type != null,EmsExportDataRecord::getType,type);
        wrapper.like(StringUtils.isNotBlank(fileName), EmsExportDataRecord::getFileName,fileName);
        wrapper.le(startTime != null,EmsExportDataRecord::getGmtCreate, startTime);
        wrapper.ge(endTime != null,EmsExportDataRecord::getGmtCreate, endTime);
        wrapper.eq(status != null,EmsExportDataRecord::getStatus,status);
        wrapper.orderByDesc(EmsExportDataRecord::getGmtCreate);
        Page<EmsExportDataRecord> page = new Page<>(pageNo, pageSize);
        return this.baseMapper.selectPage(page,wrapper);
    }

}
